package tech.aister.email;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * 本来用来演示: 邮箱功能测试
 *
 * @author success
 * @date 2025/2/26 15:50:56
 */
@SpringBootTest
public class EmailTest {
    @Autowired
    private JavaMailSender mailSender;

    /**
     * 测试邮箱发送的功能
     */
    @Test
    public void testEmail(){
        //1. 定义一个对象,封装邮件的信息
        SimpleMailMessage msg = new SimpleMailMessage();
        //邮件的发送方,此处的邮箱应该和application-dev.yml中的配置的mail下的username保持一致
        msg.setFrom("849962874@qq.com");
        //邮件的标题
        msg.setSubject("city-login验证码");
        //邮件的正文内容
        msg.setText("666666");
        //邮件的接收方
        msg.setTo("849962874@qq.com");

        //真正发送
        mailSender.send(msg);
    }
}